<#import "/layout/mainLayout.html" as mainLayout />

<#macro mainheading>

</#macro>
<#assign mainheading = mainheading in mainLayout />

<#macro maincontent>


    <script src="/js/jquery/jquery.form.js"></script>
    <script src="/js/jquery/jquery-2.1.4.min.js"></script>
    <script src="/plugins/ALTE/plugins/input-mask/jquery.inputmask.js"></script>
    <script src="/plugins/ALTE/plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
    <script src="/plugins/ALTE/plugins/input-mask/jquery.inputmask.extensions.js"></script>
    <script src="/plugins/daterangepicker/daterangepicker.js"></script>
    <script src="/plugins/timepicker/bootstrap-timepicker.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
    <script>
        $(function () {
            $('#reservation').daterangepicker();
            });
    </script>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <div class="row">
                            <div class="col-sm-12" id="filmtypecontent">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-2">
                                <select class="form-control" id="input_fState">
                                    <option value="-1">--状态--</option>
                                    <option value="0">提交订单</option>
                                    <option value="1">充值成功</option>

                                </select>
                            </div>
                            <div class="col-sm-2">
                                <select class="form-control" id="input_fBilltype">
                                    <option value="-1">--支付类型--</option>
                                    <option value="0">支付宝</option>
                                    <option value="1">微信</option>
                                    <option value="2">银行卡</option>
                                    <option value="3">其他</option>
                                </select>
                            </div>
                            <div class="col-sm-2">
                                <select class="form-control" id="input_fClasstype">
                                    <option value="-1">--视频的类型--</option>
                                    <option value="1">电影</option>
                                    <option value="2">电视剧</option>
                                    <option value="3">综艺</option>
                                    <option value="4">动漫</option>
                                </select>
                            </div>
                            <div class="col-sm-2">
                                <select class="form-control" id="input_fApptype">
                                    <option value="-1">--设备的类型--</option>
                                    <option value="1">后台触发</option>
                                    <option value="2">web登录</option>
                                    <option value="3">客户端登录</option>
                                    <option value="4">android端登录</option>
                                    <option value="5">ios登录</option>
                                </select>
                            </div>

                            <div class="col-sm-2">
                                <select class="form-control" id="input_isoff">
                                    <option value="-1">--状态--</option>
                                    <option value="0">正常</option>
                                    <option value="1">过期</option>

                                </select>
                            </div>

                            <div class="form-group">
                                <div class="input-group">
                                    <div class="input-group-addon">
                                        <i class="fa fa-calendar"></i>
                                    </div>
                                    <input type="text" class="form-control pull-right" id="input_timeSection" placeholder="日期范围"/>
                                </div><!-- /.input group -->
                            </div>

                            <div class="col-sm-1 pull-right">
                                <button class="btn btn-block btn-default " id ="btn_search" onclick="searchBuyLogList()">查询
                                </button>
                            </div>
                        </div><!-- /.box-header -->
                    </div>

                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>视频名称</th>
                                <th>用户名称</th>
                                <th>支付类型</th>
                                <th>视频类型</th>
                                <th>金额</th>
                                <th>消费名称</th>
                                <th>设备类型</th>
                                <th>添加时间</th>
                                <th>过期时间</th>
                                <th>状态</th>
                            </tr>
                            </thead>
                            <tbody id="bodycontent">


                            </tbody>
                        </table>
                    </div><!-- /.box-body -->
                    <div id="pagecontent" class="pagination"></div>
                </div><!-- /.box -->
            </div>
        </div>
    </section>

</#macro>
<#assign maincontent = maincontent in mainLayout />

<#macro mainfooter>
    <!--layoutmain footer...-->
    <!--<br />-->

    <script type="text/javascript">
        var buyLog_data = {};
        function searchBuyLogList() {

            buyLog_data = {
                fState:$('#input_fState').val(),
                fBilltype:$('#input_fBilltype').val(),
                fClasstype:$('#input_fClasstype').val(),
                fApptype:$('#input_fApptype').val(),
                isoff:$('#input_isoff').val(),
                timeSection:$('#input_timeSection').val(),
                pno: 1,
                pagesize: 10,
                allcount:-1
            };
            LoadBuyLogList();
        }
        //加载列表
        searchBuyLogList();
        function LoadBuyLogList() {
            $('#pagecontent').html('');
            $.ajax({
                    url: '/api/account/getBuyLoglist',
                    data: buyLog_data,
                    dataType: 'json',
                    success: function (data) {
                        if (mortise_layout.ValidataResult(data)) {
                            if (data.result) {
                                buyLog_data.allcount = data.result.count;
                                var html = '';
                                $.each(data.result.list, function (index, item) {
                                    html += getHtml(item);
                                })
                                $('#bodycontent').html(html);
                                ShowPage('pagecontent', buyLog_data, function (pno) {
                                    buyLog_data.pno = pno;
                                    LoadBuyLogList();
                                });
                            }
                            else {
                                alert('返回数据错误！');
                            }
                        }
                        else {
                            alert('请求数据失败！');
                        }
                    }
                }
            );
        }

        function  getHtml(dataObject) {
            var fBilltype='';
            if('0'==dataObject.fBilltype){
                fBilltype = '支付宝';
            }else if ('1'==dataObject.fBilltype){
                fBilltype = '微信';
            }else if ('2'==dataObject.fBilltype){
                fBilltype = '银行卡';
            }else {
                fBilltype = '其他';
            }

            var fClasstype='';
            if('1'==dataObject.fClasstype){
                fClasstype = '电影';
            }else if ('2'==dataObject.fClasstype){
                fClasstype = '电视剧';
            }else if ('3'==dataObject.fClasstype){
                fClasstype = '综艺';
            }else if ('4'==dataObject.fClasstype){
                fClasstype = '动漫';
            }
            var fApptype='';
            if('1'==dataObject.fApptype){
                fApptype = '后台触发';
            }else if ('2'==dataObject.fApptype){
                fApptype = 'web登录';
            }else if ('3'==dataObject.fApptype){
                fApptype = '客户端登录';
            }else if ('4'==dataObject.fApptype){
                fApptype = 'android端登录';
            }else if ('5'==dataObject.fApptype){
            fApptype = 'ios端登录';
            }
            var fOffday=dataObject.fOffday+" 23:59:59"
            fOffday=new Date(fOffday.replace("-","/"));
            var newDate = new Date();
            var fStateHtml = '';
            if (fOffday>newDate){
                fStateHtml=  '<span class="label label-danger">正常</span>'
            }else{
                fStateHtml= '<span class="label label-success">过期</span>'
            }


            return ' <tr>'+
                '<td>'+dataObject.fName+'</td>'+
                '<td>'+dataObject.fUserName+'</td>'+
                '<td>'+fBilltype+'</td>'+
                '<td>'+fClasstype+'</td>'+
                '<td>'+dataObject.fMoney+'</td>'+
                '<td>'+dataObject.fBillname+'</td>'+
                '<td>'+fApptype+'</td>'+
                '<td>'+dataObject.fIntime+'</td>'+
                '<td>'+dataObject.fOffday+'</td>'+
                '<td>'+fStateHtml+'</td>'+
                '</tr>';
        }
    </script>
</#macro>
<#assign mainfooter = mainfooter in mainLayout />
<@mainLayout.page title="用户管理"/>